﻿@model IEnumerable<WorkManagerSystem.Models.SubjectViewModel>

@{
    ViewBag.Title = "OverView";
}

<div class="row" style="margin:20px 0px">
    <div class="col-md-12">
        @if (ViewBag.msg != null && ViewBag.msg != "")
        {
            <div class="alert alert-danger text-center" role="alert">@ViewBag.msg</div>
        }
    </div>
    @using (Html.BeginForm("OverView", "Home", FormMethod.Post, new { @class = "form-inline" }))
    {
        <div class="form-group">
            <label for="bookId">书名</label>
            @Html.DropDownList("bookId", ViewBag.book as IEnumerable<SelectListItem>, new { @class = "form-control" })
        </div>
        <div class="form-group">
            <label for="bookId">班级</label>
            @Html.DropDownList("GradeId", ViewBag.grade as IEnumerable<SelectListItem>, new { @class = "form-control" })
        </div>
        <div class="form-group">
            <label for="bookId">姓名</label>
            @Html.DropDownList("studentId", ViewBag.student as IEnumerable<SelectListItem>, new { @class = "form-control" })
        </div>
        <div class="form-group">
            <label for="bookId">章节</label>
            @Html.TextBox("charpt", null, new { @class = "form-control", placeholder = "请输入章节" })
        </div>
        <div class="form-group">
            <button class="btn btn-primary">查询</button>
        </div>

    }

</div>
<table class="table table-bordered">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.BookName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GradeName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StudentName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.SoundCodePath)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Grade)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Remark)
        </th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.BookName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.GradeName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StudentName)
            </td>
            <td>
                @if (!string.IsNullOrEmpty(item.SoundCodePath))
                {
                    <label class="label label-success">已提交</label>
                }
                else
                {
                    <label class="label label-danger">未提交</label>
                }
                @*@Html.DisplayFor(modelItem => item.CreateTime)*@
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Grade)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Remark)
            </td>
        </tr>
    }

</table>
<p class="text-center">
    未完成：@ViewBag.unFinishCount / 已完成：@ViewBag.finishCount / 总数：@ViewBag.sum
</p>
@section scripts{
    <script>
        $(function () {
            $('#GradeId').change(function () {
                if ($(this)) {
                    if ($(this).val() != 0) {
                        $.get(
                            '/home/getStudent',
                            { gradId: $(this).val() },
                            function (result) {
                                var myHTML = "";
                                $('#studentId').html("");//赋值之前先清空
                                $.each(result, function (i, data) {
                                    myHTML += "<option value=" + data.Value + ">" + data.Text + "</option>";

                                });
                                $('#studentId').append(myHTML);
                            }
                        );
                    }
                }

            });
        });
    </script>
}